package com.sudo.boot.netty.packet;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.util.concurrent.EventExecutorGroup;

public class MessageEncoder extends MessageToByteEncoder<MessageProtocol> {

    @Override
    protected void encode(ChannelHandlerContext ctx, MessageProtocol mp, ByteBuf byteBuf) throws Exception {
        byteBuf.writeInt(mp.getLength());
        byteBuf.writeBytes(mp.getContent());
    }
}
